desc "convert some textmate bundles to yasnippets"
task :convert_bundles do
      Dir.glob "bundles/*-tmbundle" do |bundle_dir|
          puts "Converting from #{bundle_dir}"
          mode_prefix = File.basename(bundle_dir).match(/[^-]*/)[0]
          raise "Couldn't guess mode name for #{bundle_dir}" unless mode_prefix
          output = "snippets/#{mode_prefix}-mode"
          FileUtils.mkdir_p output
          sh "./yasmate.rb -d #{bundle_dir} -o #{output} -q"
        end
    end

task :clean do
      # this should spare empty dirs
      Dir.glob("snippets/*/*/").each do |dir|
                                 FileUtils.rm_rf dir unless File.exists?("#{dir}/.yas-skip")
                               end
      # this should delete all files starting with ".yas", sparing
      # just ".yas-setup.el" and ".yas-extra-substitutions.el"
      # autogenerated ones
      Dir.glob("snippets/*/.yas*").each do |file|
                                    File.delete(file) unless [".yas-setup.el", ".yasmate-extra-substitutions.el"].include?(File.basename(file))
                                  end
    end
